home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Surfer: Getting Started
/
Internet Surfer - Getting Started (Wayzata Technology)(7231)(1995).bin
/
pc
/
mac
/
bonus
/
peter_le
/
finger-1
/
my_units
/
myutilit.uni
< prev
next >
Wrap
Text File
|
1992-02-24
|
4KB
|
136 lines
unit MyUtilities;
{ This code is part of the Finger/Fingerd source code, written in THINK Pascal 4 }
{ Copyright 1991-1992 Peter N Lewis }
{ If you use this code, you must give me credit in your about box and documentation }
{ This is part of my generic library of routines }
interface
const
about_dialog_ID = 128;
help_dialog_ID = 129;
var
sysenv: sysEnvRec; { * - Setup by InitUtilities }
system7: boolean; { * }
has_waitNextEvent: boolean; { * }
has_appleEvents: boolean; { * }
has_findfolder: boolean; { * }
has_newStdFile: boolean; { * }
has_HelpMgr: boolean; { * }
has_colorQD: boolean; { * }
in_foreground: boolean; { * }
app_resfile: integer; { * }
about_dialog, help_dialog: dialogPtr;
procedure InitUtilities;
function WaitGetNextEvent (em: integer; var er: eventRecord; sleep: longInt; rgn: rgnHandle): boolean; { * }
function CheckCancel: boolean;
procedure DoHelp;
procedure DoAbout;
function SimpleClose (wp: windowPtr): boolean;
{ return true if you have to do something }
implementation
uses
MyTypes, Traps, MyUtils;
{$S Init}
procedure InitUtilities;
var
oe: OSErr;
gv: longInt;
begin
about_dialog := nil;
help_dialog := nil;
app_resfile := CurResFile;
oe := SysEnvirons(kSysEnvironsVersion, sysEnv);
system7 := sysenv.systemVersion >= $0700;
has_colorqd := sysenv.hasColorQD;
has_waitNextEvent := TrapAvailable(_WaitNextEvent);
in_foreground := true;
oe := Gestalt(gestaltAppleEventsAttr, gv);
has_appleEvents := (oe = noErr) and (gv = 1);
oe := Gestalt(gestaltFindFolderAttr, gv);
has_findfolder := (oe = noErr) and (BTST(gv, gestaltFindFolderPresent));
oe := Gestalt(gestaltStandardFileAttr, gv);
has_newStdFile := (oe = noErr) and (BTST(gv, gestaltStandardFile58));
oe := Gestalt(gestaltHelpMgrAttr, gv);
has_HelpMgr := (oe = noErr) and (BTST(gv, gestaltHelpMgrPresent));
end;
{$S}
function WaitGetNextEvent (em: integer; var er: eventRecord; sleep: longInt; rgn: rgnHandle): boolean;
begin
if has_waitNextEvent then begin {put us to sleep forever under MultiFinder}
WaitGetNextEvent := WaitNextEvent(em, er, sleep, nil);
end
else begin
SystemTask; {must be called if using GetNextEvent}
WaitGetNextEvent := GetNextEvent(em, er);
end;
end;
{$S Util2}
function CheckCancel: boolean;
var
er: eventRecord;
begin
if GetNextEvent(everyEvent, er) then
with er do
CheckCancel := (what = keyDown) and (BAND(message, charCodeMask) = ord('.')) and (BAND(modifiers, cmdKey) <> 0)
else
CheckCancel := false;
end;
{$S Util2}
procedure DoAbout;
begin
if about_dialog <> nil then begin
if FrontWindow <> about_dialog then
SelectWindow(about_dialog);
end
else begin
UseResFile(app_resfile);
SetVersionParamText('', '');
about_dialog := GetNewDialog(about_dialog_id, nil, POINTER(-1));
end;
end;
{$S Util2}
procedure DoHelp;
var
a: integer;
begin
if help_dialog <> nil then begin
if FrontWindow <> help_dialog then
SelectWindow(help_dialog);
end
else begin
UseResFile(app_resfile);
SetVersionParamText('', '');
help_dialog := GetNewDialog(help_dialog_id, nil, POINTER(-1));
end;
end;
{$S Util2}
function SimpleClose (wp: windowPtr): boolean;
{ return true if you have to do something }
begin
if wp = about_dialog then begin
DisposDialog(about_dialog);
about_dialog := nil;
SimpleClose := false;
end
else if wp = help_dialog then begin
DisposDialog(help_dialog);
help_dialog := nil;
SimpleClose := false;
end
else
SimpleClose := true;
end;
end.